<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1226">
    <meta th:name="_csrf" th:content="${_csrf.token}"/>
    <!-- 默认的header name是X-CSRF-TOKEN -->
    <meta th:name="_csrf_header" th:content="${_csrf.headerName}"/>
    <title>云商城-领劵中心</title>
    <!-- 引入图标库-->
    <link href="http://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <!--bootstrap-->
    <link rel="stylesheet" th:href="@{/static/resource/css/lib/bootstrap.min.css}"/>
    <!--    引入alibaba iconfont-->
    <link rel="stylesheet" href="//at.alicdn.com/t/font_2608271_v7p87hrx9q.css">

    <!--css-->
    <link rel="stylesheet" th:href="@{/static/resource/css/reset.css}"/>
    <link rel="stylesheet" th:href="@{/static/resource/css/index.css}"/>
    <link rel="stylesheet" th:href="@{/static/resource/css/cart.css}"/>
    <link rel="stylesheet" th:href="@{/static/resource/css/home.css}"/>
    <link rel="stylesheet" th:href="@{/static/resource/css/order.css}"/>
    <link rel="stylesheet" th:href="@{/static/resource/css/common/common.css}"/>
    <link rel="stylesheet" th:href="@{/static/js/directives/css/search.css}"/>
    <link rel="stylesheet" th:href="@{/static/js/directives/css/focusImg.css}"/>
    <link rel="stylesheet" th:href="@{/static/js/directives/css/focusImgMult.css}"/>
    <link rel="stylesheet" th:href="@{/static/js/directives/css/ulBox2.css}"/>
</head>

<style>


    #couponsBox {

        width: 100%;
        height: 726px;

    }

    #coupons {
        width: 1250px;
        height: 1200px;
        margin: 0 auto;

    }


    .topbar a:hover{
        color: orange;
    }
    * {
        box-sizing: border-box;
    }

    #container {
        width: 300px;
        height: 42px;
        margin: 0 auto;
    }

    div.search {
        padding: 30px 0;
    }

    form {
        position: relative;
        width: 300px;
        margin: 0 auto;
    }

    input, button {
        border: none;
        outline: none;
    }

    input {
        width: 100%;
        height: 42px;
        padding-left: 13px;
    }

    button {
        height: 42px;
        width: 42px;
        cursor: pointer;
        position: absolute;
    }

    /* 下拉框*/

    .dropbtn {
        border: none;
        cursor: pointer;
    }

    .dropdown {
        position: relative;
        display: inline-block;
        z-index: 100;
        margin-left:25px
    }

    .dropdown-content {
        display: none;
        background-color: #f9f9f9;
        min-width: 50px;
        overflow: auto;
        box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
        z-index: 1;
    }

    .dropdown-content a {
        color: black;
        text-decoration: none;
        display: block;
    }

    .dropdown a:hover {background-color: #f1f1f1}

    .show {display:block;}

/*    优惠券*/

    .coupon{
        position:relative;
        background:#d51d27;
        color:#fff;
        width: 550px;
        height:78px;
        line-height:25px;
        overflow:hidden;
        margin-top:15px;
        float: left;
        margin-right: 50px;
    }
    .coupon-diabled{
        background:#c3c3c3;
        color:#666;

    }
    .coupon:after{
        content:".";
        display:block;
        height:0;
        clear:both;
        visibility:hidden;

    }
    .coupon-money .sum{
        font-size:25px;
    }
    .coupon-left{
        float:left;
        text-align:left;
        width:60%;
        font-size:12px;
        background:url(./circle-border-left.png) left center no-repeat;
    }
    .coupon-right{
        float:right;
        text-align: center;
        width:40%;
        font-size:14px;
        background:url(./circle-border-right.png) right center no-repeat;

    }
    .coupon-inner{
        padding:10px 15px;
        height:75px;
        position: relative;
    }
    .coupon-right .coupon-inner{
        border-left:2px dashed rgba(255,255,255,.5);
    }
    .coupon-money,.coupon-time{
        margin-top:12px;
    }
    .coupon-circle{
        display:inline-block;
        width:16px;
        height:16px;
        background:#fff;
        position: absolute;
        left:-9px;
        border-radius:50%;
    }
    .coupon-circle.top{
        top:-8px;
    }
    .coupon-circle.bottom{
        bottom:-8px;
    }
    .coupon-light{
        position:absolute;
        top:20px;
        left:20%;
        height:150px;
        width:100%;
        background:rgba(255,255,255,.2);
        transform: rotate(-30deg);
        -webkit-transform: rotate(-30deg);
        -moz-transform: rotate(-30deg);
    }

    .liji{

        color: #FFFFFF;
        /*text-decoration: none;*/

    }
    .spanStyle {
        white-space: nowrap; /*强制span不换行*/
        display: inline-block; /*将span当做块级元素对待*/
        width: 190px; /*限制宽度*/
        overflow: hidden; /*超出宽度部分隐藏*/
        text-overflow: ellipsis; /*超出部分以点号代替*/
        font-size: 15px;
    }

</style>

<body>
<!-- jquery.js angular.js-->
<script th:src="@{/static/resource/lib/jquery.min.js}"></script>
<script th:src="@{/static/resource/lib/angular.js}"></script>

<!--头部工具栏-->
<div class="topbar">
    <div class="container">
        <div class="topbar_nav fl">
            <ul>
                <li><a th:href="@{/web/index/}">首页</a></li>
                <li><a th:href="@{/web/couponsActivity/toCouponsActivity}">领劵中心</a></li>
                <li><a th:href="@{/web/seckill/toSearchSeckillPage}">秒杀</a></li>
                <li><a href="https://github.com/youzhengjie9/cloud-mall">项目链接</a></li>
            </ul>
        </div>
        <div class="topbar_cart fr">
            <a href="/web/cart/tocart">购物车</a>
        </div>
        <div class="topbar_cart fr">
            <a href="/web/order/toOrderPage">我的订单</a>
        </div>
        <div class="topbar_cart fr">
            <a href="/web/seckill/toSeckillSuccessList">秒杀成功订单</a>
        </div>
        <div class="topbar_info fr" style="width:220px">
            <form name="logoutform" th:action="@{/web/logout/logout}" method="post"></form>
            <a class="nav-link" th:href="@{/web/register/toregister}">注册</a>
            <a class="nav-link" sec:authorize="isAnonymous()" th:href="@{/web/login/toLoginPage}">登录</a>
            <a sec:authorize="isAuthenticated()" class="nav-link dropbtn" onclick="myFunction()">[[${username}]]</a>
            <a href="#" onclick="kefu(1)">人工客服</a>
            <div class="dropdown">
                <div id="myDropdown" class="dropdown-content" style="width: 120px;height: 70px">
                    <a th:href="@{/web/center/toBaseInfo}" style="width: 100px;height: 30px;">个人中心</a>
                    <a href="javascript:document.logoutform.submit();" style="width: 100px;height: 30px;">退出登录</a>
                </div>
            </div>
        </div>
    </div>
</div>



<div id="couponsBox">


    <!--    所有优惠券div-->
    <div id="coupons">

        <!--可用-->
        <div class="coupon" th:each="coupons:${couponsActivities}">
            <div class="coupon-left">
                <div class="coupon-inner">
                    <div class="coupon-money">
                        <span>¥</span>
                        <span class="sum" th:text="${coupons.getAmount()}"></span>
                        <span class="spanStyle">&nbsp;&nbsp;[[${coupons.couponsName}]]</span>
                    </div>
                    <div class="coupon-condition">
                        <p>满[[${coupons.minPoint}]]可用
                            &nbsp;&nbsp;使用期限:[[${coupons.startTime}]]~[[${coupons.endTime}]]
                        </p>
                    </div>
                </div>
            </div>
            <div class="coupon-right">
                <div class="coupon-inner">
                    <br />
                    <a style="cursor: pointer" class="liji" th:onclick="getcoupons([[${coupons.id}]])">立即领劵</a>
                    <i class="coupon-circle top"></i>
                    <i class="coupon-circle bottom"></i>
                </div>
            </div>
<!--            <div class="coupon-light"></div>-->
        </div>

    </div>

</div>






<!--footer-->
<footer class="footer">
    <div class="container">
        <div class="footer_service">
            <ul class="clearfix">
                <li><a href="">1小时快修服务</a></li>
                <li><a href="">7天无理由退货</a></li>
                <li><a href="">30天免费换货</a></li>
                <li><a href="">满200元包邮</a></li>
                <li><a href="">520余家售后网点</a></li>
            </ul>
        </div>

        <div class="footer_link clearfix">
            <dl>
                <dt>帮助中心</dt>
                <dd>购物指南</dd>
                <dd>支付方式</dd>
                <dd>配送方式</dd>
            </dl>
            <dl>
                <dt>帮助中心</dt>
                <dd>购物指南</dd>
                <dd>支付方式</dd>
                <dd>配送方式</dd>
            </dl>
            <dl>
                <dt>帮助中心</dt>
                <dd>购物指南</dd>
                <dd>支付方式</dd>
                <dd>配送方式</dd>
            </dl>
            <dl>
                <dt>帮助中心</dt>
                <dd>购物指南</dd>
                <dd>支付方式</dd>
                <dd>配送方式</dd>
            </dl>
            <dl>
                <dt>帮助中心</dt>
                <dd>购物指南</dd>
                <dd>支付方式</dd>
                <dd>配送方式</dd>
            </dl>
            <dl>
                <dt>帮助中心</dt>
                <dd>购物指南</dd>
                <dd>支付方式</dd>
                <dd>配送方式</dd>
            </dl>

            <div class="footer_contact">
                <p class="phone">18420163207</p>

                <p><span style="">周一至周日 8:00-18:00</span>
                    <span style="display:none;">2月7日至13日服务时间 7:00-18:00</span><br>（仅收市话费）</p>
                <a rel="nofollow" class="btn btn-primary btn-small" href="#">24小时在线客服</a>
            </div>
        </div>

    </div>

    <div class="footer_site">
        <div class="container">
            <div class="cart_log">
                <a href="" title="云商城"></a>
            </div>
            <div>
                <p>云商城项目由本人自己完成,如有不足,请指正！</p>
            </div>
        </div>
    </div>
</footer>


</body>


<script th:inline="javascript">

    //js提交表单
    function submitData() {
        document.getElementById("form").submit();
    }
    /* 点击按钮，下拉菜单在 显示/隐藏 之间切换 */
    function myFunction() {
        document.getElementById("myDropdown").classList.toggle("show");
    }

    // 获取<meta>标签中封装的_csrf信息 ,否则会请求403
    var token = $("meta[name='_csrf']").attr("content");
    var header = $("meta[name='_csrf_header']").attr("content");
    var headers = {"X-CSRF-TOKEN": token};


    //ajax领取优惠券
    function getcoupons(cid)
    {

        $.ajax({
            url:'/web/couponsRecord/getCoupons',
            data:
                {
                    "couponsid": cid
                },
            type:'GET',
            dataType:'json',
            success:function(result){
                if(result.success){
                    alert(result.msg);
                }else{
                    alert(result.msg);
                }
            },
            error:function () {
                alert('领取失败')
            }
        })

    }


    // 点击下拉菜单意外区域隐藏
    window.onclick = function(event) {
        if (!event.target.matches('.dropbtn')) {

            var dropdowns = document.getElementsByClassName("dropdown-content");
            var i;
            for (i = 0; i < dropdowns.length; i++) {
                var openDropdown = dropdowns[i];
                if (openDropdown.classList.contains('show')) {
                    openDropdown.classList.remove('show');
                }
            }
        }
    }


    function kefu(e) {
        $.ajax({
            url:'/web/chat/HasGotoKefu',
            dataType:'json',
            type:'get',
            success:function(result){

                if(result==true){
                    window.location.href='http://localhost:5677/chat/toChat';
                }else {
                    alert('当前咨询人数过多,客服都忙不过来了,请等会儿再咨询！')
                }

            },
            error:function () {
                alert('您可能还没有登录,请登录!')
            }
        })

    }
</script>


</html>